package com.goldgov.code.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.goldgov.code.dao.UserDao;
import com.goldgov.code.service.User;
import com.goldgov.code.service.UserService;

@Service
public class UserServiceImpl implements UserService{

	@Autowired
	private UserDao userDao;
	
	@Override
	public User getUser(String loginName, String password) {
		return userDao.getUser(loginName, password);
	}

	@Override
	public boolean updatePassword(String loginName, String oldPwd, String newPwd) {
		User user = getUser(loginName,oldPwd);
		if(user == null) {
			return false;
		}
		userDao.updatePassword(user.getUserID(), newPwd);
		return true;
	}
	
}
